package com.gome.axwl.aoc.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gome.axwl.aoc.dao.ContractDao;
import com.gome.axwl.aoc.entity.po.ContractPo;
import com.gome.axwl.aoc.service.ContractService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

/**
 * Created by wanglongyu on 2018/7/13.
 */
@Service
public class ContractServiceImpl implements ContractService{

    @Autowired
    private ContractDao contractDao;
    @Override
    public PageInfo<ContractPo> queryContract(String contractName, String contractNo,String carrierPhone,String carrierName,
                                              Integer status, Date startTime, Date endTime, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum==null?1:pageNum,pageSize==null?10:pageSize);
        List<ContractPo> contractPos = contractDao.queryContract(contractName,contractNo,carrierPhone,carrierName,status,startTime,endTime);
        PageInfo<ContractPo> pageInfo=new PageInfo<>(contractPos);
        return pageInfo;
    }

    @Override
    public int addContract(ContractPo contractPo) {
        return contractDao.addContract(contractPo);
    }

    @Override
    public ContractPo getByApplyInfoId(Integer applyInfoId) {
        return contractDao.getByApplyInfoId(applyInfoId);
    }

    @Override
    public int sign(String signPerson, Integer applyInfoId, Date modifyTime) {
        return contractDao.sign(signPerson, applyInfoId, modifyTime);
    }

    @Override
    public int pass(String signPerson, Integer auditStatus, Integer applyInfoId, Date modifyTime) {
        return contractDao.pass(signPerson, auditStatus, applyInfoId, modifyTime);
    }

    @Override
    public int unpass(String unpassReason, Integer auditStatus, Integer applyInfoId, Date modifyTime) {
        return contractDao.unpass(unpassReason, auditStatus, applyInfoId, modifyTime);
    }

    @Override
    public ContractPo queryByContractNo(String contractNo) {
        return contractDao.queryByContractNo(contractNo);
    }

}
